{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}尚硅谷书店-商品列表{% endblock title %}
{% block topfiles %}
{% endblock topfiles %}
{% block body %}

    <div class="navbar_con">
        <div class="navbar clearfix">
            <div class="subnav_con fl">
                <h1>全部商品分类</h1>   
                <span></span>           
                <ul class="subnav">
                    <li><a href="#" class="python">Python</a></li>
                    <li><a href="#" class="javascript">Javascript</a></li>
                    <li><a href="#" class="algorithms">数据结构与算法</a></li>
                    <li><a href="#" class="machinelearning">机器学习</a></li>
                    <li><a href="#" class="operatingsystem">操作系统</a></li>
                    <li><a href="#" class="database">数据库</a></li>
                </ul>
            </div>
            <ul class="navlist fl">
                <li><a href="">首页</a></li>
                <li class="interval">|</li>
                <li><a href="">移动端书城</a></li>
                <li class="interval">|</li>
                <li><a href="">秒杀</a></li>
            </ul>
        </div>
    </div>

    <div class="breadcrumb">
        <a href="#">全部分类</a>
        <span>></span>
        <a href="#">{{ type_title }}</a>
    </div>

    <div class="main_wrap clearfix">
        <div class="l_wrap fl clearfix">
            <div class="new_book">
                <h3>新品推荐</h3>
                <ul>
                    {% for book in books_new %}
                    <li>
                        <a href="{% url 'books:detail' books_id=book.id %}"><img src="{% static book.image %}"></a>
                        <h4><a href="{% url 'books:detail' books_id=book.id %}">{{ book.name }}</a></h4>
                        <div class="prize">￥{{ book.price }}</div>
                    </li>
                    {% endfor %}
                </ul>
            </div>
        </div>

        <div class="r_wrap fr clearfix">
            <div class="sort_bar">
                <a href="/list/{{ type_id }}/1/" {% if sort == 'default' %}class="active"{% endif %}>默认</a>
                <a href="/list/{{ type_id }}/1/?sort=price" {% if sort == 'price' %}class="active"{% endif %}>价格</a>
                <a href="/list/{{ type_id }}/1/?sort=hot" {% if sort == 'hot' %}class="active"{% endif %}>人气</a>
            </div>

            <ul class="book_type_list clearfix">
                {% for book in books_li %}
                    <li>
                        <a href="{% url 'books:detail' books_id=book.id %}"><img src="{% static book.image %}"></a>
                        <h4><a href="{% url 'books:detail' books_id=book.id %}">{{ books.name }}</a></h4>
                        <div class="operate">
                            <span class="prize">￥{{ book.price }}</span>
                            <span class="unit">{{ book.unit }}</span>
                            <a href="#" class="add_books" title="加入购物车"></a>
                        </div>
                    </li>
                {% endfor %}
            </ul>

            <div class="pagenation">
                {% if books_li.has_previous %}
                    <a href="/list/{{ type_id }}/{{ books_li.previous_page_number }}/?sort={{ sort }}"><上一页</a>
                {% endif %}
                {% for pindex in pages %}
                    {% if pindex == books_li.number %}
                        <a href="/list/{{ type_id }}/{{ pindex }}/?sort={{ sort }}" class="active">{{ pindex }}</a>
                    {% else %}
                        <a href="/list/{{ type_id }}/{{ pindex }}/?sort={{ sort }}">{{ pindex }}</a>
                    {% endif %}
                {% endfor %}
                {% if books_li.has_next %}
                    <a href="/list/{{ type_id }}/{{ books_li.next_page_number }}/?sort={{ sort }}">下一页></a>
                {% endif %}
            </div>
        </div>
    </div>
{% endblock body %}
